from flask import Flask
from app_config import config
from flask_sqlalchemy import SQLAlchemy
from app.models import db
from flask_cors import CORS


def GenertateApp():
	from app.api import app_api, restful_api
	from app.api_web import web_api
	app = Flask("app")
	app.config['SECRET_KEY'] = '123456'
	app.config["SQLALCHEMY_DATABASE_URI"] = config.get_postgres_url()
	app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
	app.register_blueprint(app_api, url_prefix='/api/v1')
	app.register_blueprint(web_api, url_prefix='/')
	db.init_app(app)
	CORS(app, supports_credentials=True)
	return app


app = GenertateApp()
